<template>
  <view class="page">
    <custom-navbar title="首页" :showBack="true" titleColor="#333333">
    </custom-navbar>

    <up-tabbar
      :value="value1"
      @change="change1"
      :fixed="false"
      :placeholder="false"
      :safeAreaInsetBottom="false"
    >
      <up-tabbar-item text="首页" icon="home" @click="click1"></up-tabbar-item>
      <up-tabbar-item
        text="放映厅"
        icon="photo"
        @click="click1"
      ></up-tabbar-item>
      <up-tabbar-item
        text="直播"
        icon="play-right"
        @click="click1"
      ></up-tabbar-item>
      <up-tabbar-item
        text="我的"
        icon="account"
        @click="click1"
      ></up-tabbar-item>
    </up-tabbar>
  </view>
</template>

<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
import { storeToRefs } from "pinia";
import { getTest, postTest, userInfoApi } from "@/common/request/api/index.js";
import { useUserStore } from "@/stores/user";
const show = ref();

const value1 = ref(0);
function click1(e) {
  console.log(e);
}

// 请求
function getTestData() {
  // show.value = 1;
  // console.log(show.value);
  getTest().then((res) => {
    // console.log(res);
  });
}

function postTestData() {
  const postData = {
    pageNum: 1,
    pageSize: 10,
    countryCode: "CN",
    cityCode: "CN_C_76142",
  };
  postTest(postData).then((res) => {
    // console.log(res);
  });
}

function aaa() {
  uni.navigateTo({
    url: "/pages/index/index2",
  });
}

onLoad(() => {
  getTestData();
  postTestData();
});
// ---------------------------------------------------

// pinia
const user = useUserStore();
// 如果要用解构  要收用storeToRefs才能变为响应式
// const { userInfo } = storeToRefs(user);
async function handleLogin() {
  let userInfo = await userInfoApi();
  user.setUserInfo(userInfo);
}
// --------------------------------------------------------
</script>

<style lang="scss" scoped>
.page {
  padding-top: calc(var(--status-bar-height) + 44px);
}
.scss-test {
  font-size: 28rpx;
  color: $theme;
}
</style>
